/** 
* All Rights Reserved , Copyright (C) 2022 , 青岛鼎信通讯股份有限公司
* 
* AppAreaInitializationConfigServiceAuto
* 区域初始化配置
* 
* 修改纪录
* 2022-12-23 版本：1.0 wuyuyang 创建。
* @version 版本：1.0
* @author 作者：wuyuyang
* 创建日期：2022-12-23
*/

package com.topscomm.appv2.service.impl.auto;

import javax.annotation.Resource;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.topscomm.appv2.pojo.AppAreaInitializationConfigEntity;
import com.topscomm.basic.IBasicDao;
import com.topscomm.pub.util.ConvertUtil;
import com.topscomm.tap.common.DatacodeCache;

import java.util.HashMap;
import java.util.Map;
import com.topscomm.appv2.*;
import com.topscomm.appv2.dao.IAppAreaInitializationConfigDao;


public class AppAreaInitializationConfigServiceAuto extends Appv2Service<AppAreaInitializationConfigEntity,IAppAreaInitializationConfigDao> {
	
	/**
	 * @author: wuyuyang
	 * @date: 2022-12-23
	 * @param mapRow
	 * @description:设置字段显示值
	 * @modify:
	 */
	@Override
	public void setDispFields(Map<String, Object> mapRow, DatacodeCache datacodeCache) {
		String temp;
		if (mapRow.get("areacode") != null) {
			temp = mapRow.get("areacode").toString();
			mapRow.put("dispareacode", datacodeCache.getValueDynamic("AppAreaType", temp, "code", "name"));
		}
		if (mapRow.get("publish") != null) {
			temp = mapRow.get("publish").toString();
			mapRow.put("disppublish", datacodeCache.getValueDynamic("CboYesNo", temp, "code", "name"));
		}
		if (mapRow.get("enabled") != null) {
			temp = mapRow.get("enabled").toString();
			mapRow.put("dispenabled", datacodeCache.getValueDynamic("CboYesNo", temp, "code", "name"));
		}
		// 处理默认值显示值
		if (mapRow.get("defaultvalue") != null) {
			temp = mapRow.get("defaultvalue").toString();
//			mapRow.put("dispenabled", datacodeCache.getValueDynamic("CboYesNo", temp, "code", "name"));
			JSONArray array = JSON.parseArray(temp);
			String res = "";
			for (int i = 0; i < array.size(); i++) {
				JSONObject jsonObject = array.getJSONObject(i);
				res += ConvertUtil.convertToString(jsonObject.get("name")) + ",";
			}
			res = res.substring(0, res.length()-1);
			mapRow.put("dispdefaultvalue",res);
		}
	}

	@Override
	@Resource(name = "appAreaInitializationConfigDao")
	public void setDao(IBasicDao<AppAreaInitializationConfigEntity> dao) {		
		super.setDao(dao);
	}
}
